<template>
  <div class="table-form">
    <el-form ref="formRef" :model="form" :inline="true" class="pro-select-box">
      <el-form-item label="配方类型:" prop="recipe_type">
        <el-input v-model="form.recipe_type" clearable placeholder="配方类型" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="query" :loading="loading"
          >查询</el-button
        >
        <!-- <el-button type='success' @click='output' :loading='downloading'>导出</el-button> -->
        <el-button type="success" @click="addForm">新增</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <hcTable
      :table-data="list"
      :options="options"
      :columns="tableColumn"
      @size-change="handlerPageSize"
      @current-change="handlerPageIndex"
      @command="handleAction"
    >
      <template #enabled="{ row }">{{
        row.enabled ? "可用" : "禁用"
      }}</template>
      <template #station_id="{ row }">{{ row.station.station_code }}</template>
    </hcTable>
    <addAndEdit :options="editOption" @closeDialog="closeDialog" />
  </div>
</template>

<script setup>
import { reactive } from "vue";
import addAndEdit from "./dialog/addAndEdit.vue";
import useQueryTable from "@/hooks/useQueryTable";

let form = reactive({
  recipe_type: "",
});

let tableColumn = [
  { type: "index", width: "60", label: "序号", align: "center", fixed: true },
  { prop: "recipe_type", label: "配方类型", align: "center" },
  { prop: "attribute_type", label: "属性类型", align: "center" },
  {
    prop: "station_id",
    label: "工站编号",
    align: "center",
    slot: "station_id",
  },
  {
    prop: "enabled",
    label: "是否可用",
    align: "center",
    slot: "enabled",
    sortable: true,
  },
  {
    width: "120",
    label: "操作",
    align: "center",
    buttons: [
      {
        name: "编辑",
        type: "warning",
        command: "edit",
      },
      // {
      //   name: "删除",
      //   type: "danger",
      //   command: "delete",
      // },
    ],
  },
];

let {
  list,
  query,
  output,
  addForm,
  options,
  loading,
  editOption,
  downloading,
  closeDialog,
  handleAction,
  handlerPageSize,
  handlerPageIndex,
} = useQueryTable(
  { get: "/AvpRecipeType/GetPageList", del: "/AvpRecipeType/Delete" },
  form
);
</script>

<style lang="scss" scoped></style>
